<template>
    <a-card :bordered="false">
        <div class="table-operator">
            <a-button shape="round" size="small" type="primary" icon="plus" @click="handleAdd()">添加</a-button>
        </div>
        <a-spin :spinning="confirmLoading" tip="Loading...">
            <LTable
                ref="leaveTestList"
                size="middle"
                rowKey="keyId"
                :formAttributes="formAttributes"
                :columns="columns"
                axiosUrl="/leaveInfo/list"
                :showPagination="true"
                :httpRequest="request"
                :showQueryForm="true">

                <span slot="action" slot-scope="text, record">
                    <a @click="handleDetail(record)">编辑</a><a-divider type="vertical" />
                    <a @click="handleDelete(record)">删除</a><a-divider type="vertical" />
                </span>
            </LTable>
        </a-spin>

        <leave-test-modal ref="leaveTestModal" @handleClose="refresh('leaveTestList')"></leave-test-modal>
    </a-card>
</template>

<script>
import LTable from '@/components/lt/LTable' 
import request from '@/utils/flowRequest'
import {SysMixin} from '@/mixins/SysMixin'
import leaveTestModal from './leaveTestModal'

export default {
    name: 'leaveTestList',
    components: {
       LTable, leaveTestModal
    },
    mixins: [SysMixin],
    data() {
        return {
            request,
            confirmLoading: false,
            url: {
                
            },
            formAttributes: [
                {field:'userName',label:'请假人姓名',component:'input',condition:'like'},
                {field:'startTime',label:'请假开始时间',component:'date',condition:'ge'},
                {field:'userName',label:'请假结束时间',component:'date',condition:'le'},
            ],
            columns: [
                {
                    title: '#',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                      return parseInt(index)+1;
                    }
                },
                {
                    title: '请假人姓名',
                    dataIndex: 'userName'
                },
                {
                    title: '请假天数',
                    dataIndex: 'leaveNum'
                },
                {
                    title: '开始时间',
                    dataIndex: 'startTime'
                },
                {
                    title: '结束时间',
                    dataIndex: 'endTime'
                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    width: 200,
                    scopedSlots: { customRender: 'action' }
                }
            ]
        }
    },
    methods: {
        handleAdd(record) {
            this.$refs['leaveTestModal'].open()
        },
        handleDetail(record) {
            this.$refs['leaveTestModal'].open(record)
        },
        handleDelete(record) {

        }
    }
}
</script>
